<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p class="city-p"></p>
    <script>
        // 目标:使用XHR携带查询参数，展示某个省下属的城市列表
        const xhr = new XMLHttpRequest()
        xhr.open('GET', 'http://hmajax.itheima.net/api/city?pname=辽宁省')
        xhr.addEventListener('loadend', () => {
            console.log(xhr.response); //json数据

            const data = JSON.parse(xhr.response)
            console.log(data.list); //数组
            // data.list.join('<br>')转字符串
            document.querySelector('.city-p').innerHTML = data.list.join('<br>')
        })
        xhr.send()
    </script>
</body>

</html>